package org.example.configs;

import org.example.utils.SnowflakeIdGenerator;
import org.example.utils.WorkerIdAssigner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SnowflakeConfig {

    @Autowired
    private WorkerIdAssigner workerIdAssigner;

    @Bean
    public SnowflakeIdGenerator snowflakeIdGenerator() {
        long workerId = workerIdAssigner.getWorkerId();
        return new SnowflakeIdGenerator(workerId, 0);
    }
}